package reflect;

import java.lang.reflect.Method;
import java.util.Scanner;

public class ReflectDemo02 {
    public static void main(String[] args) throws Exception{
        Scanner scan = new Scanner(System.in);
        String className = scan.nextLine();
        Class clazz = Class.forName(className);
        Object obj = clazz.newInstance();
        Method[] methods = clazz.getDeclaredMethods();
        for (Method mh: methods) {
            Class[] types = mh.getParameterTypes();
            Object rv = null;
            //只调用以"text"开头的代码
            if(mh.getName().startsWith("test")){
                if(types.length == 0){
                    rv = mh.invoke(obj);
                }else{
                    Object[] params = new Object[types.length];
                    for (int i = 0; i < params.length; i++) {
                        if(params[i] == String.class){
                            params[i] = "阿巴阿巴";
                        }
                        if(params[i] == int.class){
                            params[i] = "12312312";
                        }
                    }
                    rv = mh.invoke(obj,params);
                }
                System.out.println("rv:"+rv);
            }
        }
    }
}
